﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Clinica_Frba.Login
{
    public partial class Form2 : Form
    {
        public Form2(List<string> listRol)
        {
            InitializeComponent();
            foreach (string rol in listRol)
            {
                cBRols.Items.Add(rol);
            }
        }
        public Form2(int id_usu)
        {
            InitializeComponent();
            SqlConnection myConnection = new SqlConnection(publico.ConnectionString);
            myConnection.Open();
            SqlCommand consulta = new SqlCommand("SELECT ROL.ID_ROL,NOMBRE_ROL FROM ROL LEFT JOIN ROL_USUARIO ON ROL.ID_ROL=ROL_USUARIO.ID_ROL LEFT JOIN USUARIO ON USUARIO.ID_USU=ROL_USUARIO.ID_USU WHERE USUARIO.ID_USU="+id_usu,myConnection);
            SqlDataReader executeCMD = consulta.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Columns.Add("id_rol");
            dt.Columns.Add("nombre_rol");
            dt.Load(executeCMD);
            cBRols.DisplayMember="nombre_rol";
            cBRols.ValueMember="id_rol";
            cBRols.DataSource=dt;
            cBRols.SelectedIndex = 0;
            myConnection.Close();
        }
        private void goButton_Click(object sender, EventArgs e)
        {
            this.Hide();
            String sTipo = cBRols.SelectedValue.ToString();
            Principal fp = new Principal(sTipo);
            fp.Show();

            
        }

        private void cBRols_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }
    }
}
